<?php

namespace app\api\controller\xiluhouse;

use app\common\controller\Api;
use app\api\logic\xiluhouse\RentalContactLogic;

/**
 * 房源联系方式接口
 */
class RentalContact extends Api
{
    protected $noNeedLogin = [];
    protected $noNeedRight = ['*'];

    // VIP等级配置
    const VIP_LEVEL = 1; // 定义VIP等级最小值
    const FREE_DAILY_LIMIT = 5; // 普通用户每日免费查看次数

    /**
     * 查看房源联系方式
     *
     * @param int rental_id 房源ID
     */
    public function view()
    {
        $user = $this->auth->getUser();
        $rental_id = $this->request->post('rental_id');
        
        $logic = new RentalContactLogic();
        $result = $logic->view($rental_id, $user);
        
        if ($result['code'] === 1) {
            $this->success($result['msg'], $result['data']);
        } else {
            $this->error($result['msg']);
        }
    }

    /**
     * 获取查看限制信息
     */
    public function getLimitInfo()
    {
        $user = $this->auth->getUser();
        
        $logic = new RentalContactLogic();
        $result = $logic->getLimitInfo($user);
        
        if ($result['code'] === 1) {
            $this->success($result['msg'], $result['data']);
        } else {
            $this->error($result['msg']);
        }
    }
} 